package com.jack.lib.ui.adapter

import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.annotation.LayoutRes
import androidx.viewbinding.ViewBinding
import com.blankj.utilcode.util.ReflectUtils
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.util.getItemView
import com.jack.lib.core.ext.arguments

/**
 * 作者: jack(黄冲)
 * 邮箱: 907755845@qq.com
 * create on 2018/12/24 13:17
 */
abstract class JRBindingAdapter<VB: ViewBinding, T>(data: MutableList<T>? = null) : BaseQuickAdapter<T, JViewBindingHolder<VB>>(0, data) {

    open override fun onCreateDefViewHolder(parent: ViewGroup, viewType: Int): JViewBindingHolder<VB> {
        val binding: VB = ReflectUtils.reflect(arguments(0)).method("inflate", LayoutInflater.from(context), parent, false).get()
        return JViewBindingHolder(binding)
    }
}